home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-09-11 | 1.9 KB | 56 lines | [TEXT/CWIE] |
- // PowerPlantStoreStream.cp
- // Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
-
- // Subclass of HFSStoreStream that uses PowerPlant's support for threaded, asynch i/o.
-
- #include "PowerPlantStoreStream.h"
- #include <LThread.h>
- #include <Errors.h>
-
- PowerPlantStoreStream::PowerPlantStoreStream(short v, long d, const StringPtr n, OSType c, OSType t)
- : HFSStoreStream(v,d,n,c,t) {
- }
-
- PowerPlantStoreStream::PowerPlantStoreStream(short v, long d, const StringPtr n,
- OSType c, OSType t, bool o, bool w, short f)
- : HFSStoreStream(v,d,n,c,t,o,w,f) {
- }
-
- IAStoreStream* PowerPlantStoreStream::Clone() {
- return new PowerPlantStoreStream(vRefNum, dirID, fileName, creator, fileType,
- isOpen, isWritable, fRefNum);
- }
-
- void PowerPlantStoreStream::Write(uint32 address, const byte* data, uint32 length) {
- IAThrowIfNot(isOpen && isWritable, StoreError);
- SThreadParamBlk pb;
- LThread* thread = LThread::GetCurrentThread();
- thread->SetupAsynchronousResume(&pb);
- pb.ioPB.F.ioParam.ioRefNum = fRefNum;
- pb.ioPB.F.ioParam.ioBuffer = (Ptr)data;
- pb.ioPB.F.ioParam.ioReqCount = length;
- pb.ioPB.F.ioParam.ioPosMode = fsFromStart;
- pb.ioPB.F.ioParam.ioPosOffset = address;
- PBWrite(&pb.ioPB.F, true);
- OSErr err = thread->SuspendUntilAsyncResume(&pb);
- IAThrowIf(err, StoreError);
- IAAssert(pb.ioPB.F.ioParam.ioActCount = length);
- }
-
- uint32 PowerPlantStoreStream::Read(uint32 address, byte* data, uint32 length) {
- IAThrowIfNot(isOpen, StoreError);
- SThreadParamBlk pb;
- LThread* thread = LThread::GetCurrentThread();
- thread->SetupAsynchronousResume(&pb);
- pb.ioPB.F.ioParam.ioRefNum = fRefNum;
- pb.ioPB.F.ioParam.ioBuffer = (Ptr)data;
- pb.ioPB.F.ioParam.ioReqCount = length;
- pb.ioPB.F.ioParam.ioPosMode = fsFromStart;
- pb.ioPB.F.ioParam.ioPosOffset = address;
- PBRead(&pb.ioPB.F, true);
- OSErr err = thread->SuspendUntilAsyncResume(&pb);
- IAThrowIf(err && err != eofErr, StoreError);
- return pb.ioPB.F.ioParam.ioActCount;
- }
-